﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using ExpertStockSystem.Models;

namespace ExpertStockSystem.DAL
{
    public class WarehouseRepository
    {
        ESSDatabaseEntities db = new ESSDatabaseEntities();
        public int MaxRow()
        {
            return 10;
        }
        public int MaxColumn()
        {
            return 10;
        }
        public void AddWarehouseSpace(int row, int column)
        {
            WarehouseSpace warehouseSpace = db.WarehouseSpaceSet.First(x => x.Row == row && x.Column == column);
            if (warehouseSpace == null)
            {
                db.WarehouseSpaceSet.AddObject(new WarehouseSpace
                {
                    Column = column,
                    Enable = true,
                    Name = "XXX",
                    Row = row
                });
            }
            else
            {
                warehouseSpace.Enable = true;
            }
            db.SaveChanges();
        }
        public bool IsWarehouseSpaceAvailable(int row, int column)
        {
            if (db.WarehouseSpaceSet.Any(x => x.Row == row && x.Column == column))
                return true;
            else
                return false;
        }
    }
}
